package com.example.file.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "oss")
public class OSSProperties {
//    file:
//    max-time: 3
//    test: true
//    oss:
//    endpoint: oss-cn-hangzhou.aliyuncs.com
//    region: cn-hangzhou
//    accessKeyId: LTAI5tFaAt51tHh5so66zdDm
//    accessKeySecret: OE7Ex876uE4wFOKuyHxznbAYL8pEzl
//    bucketName: web-tmlgbd
//    pathPrefix: olinejudge/

    private String endpoint="oss-cn-hangzhou.aliyuncs.com";

    private String accessKeyId="LTAI5tFaAt51tHh5so66zdDm";

    private String accessKeySecret="OE7Ex876uE4wFOKuyHxznbAYL8pEzl";

    private String bucketName="web-tmlgbd";

    /**
     * 路径前缀，加在 endPoint 之后
     */
    private String pathPrefix="olinejudge/";

    public String getBaseUrl() {
        return "https://" + bucketName + "." + endpoint + "/";
    }

    public String getDownloadUrl(String key) {
        return getBaseUrl() + key;
    }
}
